import { createRouter, createWebHistory } from 'vue-router'
import { getBasePath, setupRouterGuards } from '@/utils/router'

// 路由配置
const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('@/views/Home.vue'),
    meta: {
      title: '首页'
    }
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('@/views/About.vue'),
    meta: {
      title: '关于'
    }
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'NotFound',
    component: () => import('@/views/NotFound.vue'),
    meta: {
      title: '404'
    }
  }
]

// 创建路由实例
const router = createRouter({
  // 使用工具函数获取基础路径
  history: createWebHistory(getBasePath()),
  routes
})

// 设置路由守卫
setupRouterGuards(router)

export default router 